<%@page import="com.wuye.entity.Users"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title></title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
  </head>
  <body>
  	<jsp:include page="driver.jsp"></jsp:include>
    <div id="tool">
				<div style="margin: 10px;">
					<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="add()">增加</a>
					<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="$('#search').dialog('open');">查询</a>
					<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="window.location.href='<%=basePath%>jiaofei/goPage.do'">刷新</a>
					<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-help',plain:true">帮助</a>
					<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-redo',plain:true" style="color: green;margin-left: 50px;">提示信息：${msg }</a>
				</div>
			</div>
			<!-- table -->
			<table id="tb" class="easyui-datagrid">
			</table>
  </body>
  <script type="text/javascript">
  	//table
  	$("#tb").datagrid({
		url:'jiaofei/allList.do',
		columns:[
			         [   
				         {field:'check',checkbox:true,rowspan:2},   
				         {field:'shijian',title:'日期',rowspan:2,width:200,align:'center'},   
				      	 {field:'xiangmu',title:'缴费项目',width:250,align:'center'},   
				         {field:'money',title:'金额',width:250,align:'right'},
				         {field:'username',title:'缴费人',width:300,align:'center'}
			      	]
		        ],
		border:false,
		striped: true,
		fit: true,
		rownumbers:true,
		ctrlSelect:true,
		pagination:true,
		toolbar: "#tool"
	});
  	//check选中数id
  	function checkId(){
		var ids = [];
		var rows = $('#tb').datagrid('getSelections');
		for(var i=0; i<rows.length; i++){
			ids.push(rows[i].id);
		}
		return ids;
	}
  //check选中数
  	function check(){
		var ids = [];
		var rows = $('#tb').datagrid('getSelections');
		for(var i=0; i<rows.length; i++){
			ids.push(rows[i]);
		}
		return ids;
	}
  	//add
  	function add(){
  		$('#add').dialog('open');
  	}
  	//del
  	function del(){
  		if(check().length>0){
	  		$("#delCount").html(check().length);
	  		$('#del').dialog('open');
  		}
  	}
  	function del2(){
  		window.location.href="user/del.do?str="+checkId();
  	}
  	//edit
  	function edit(){
  		if(check().length==1){
  			$('#edit').dialog('open');
  			$('#form2').form('load',{
				name:check()[0].name,
				id:check()[0].id,
				zhengjian:check()[0].zhengjian,
				dianhua:check()[0].dianhua,
				beizhu:check()[0].beizhu
			});
  		}else{
  			alert("只允许修改一条记录");
  		}
  	}
  	//search
  	function sousuo(){
  		var address='jiaofei/searchList.do?shijian1='+$("#shijian1").datebox('getValue')+'&shijian2='+$("#shijian2").datebox('getValue');
  		$("#tb").datagrid({
  			url:address
  		});
  		$('#search').dialog('close');
  	}
  </script>
  	<!--新增  -->
  	<div id="add" class="easyui-dialog" title="新增" data-options="iconCls:'icon-tip',closed:true,modal:true" style="width:480px;height:320px;padding:10px;">
			<div align="center">
			<form action="jiaofei/save.do" method="post" id="form1">
				<table cellpadding="5" style="color:blueviolet;margin-top: 40px;">
		    		<tr>
		    			<td>业主:</td>
		    			<td>
							<select class="easyui-combobox" name="users.id" style="width:155px;">
							<%List<Users> list=(List<Users>)request.getAttribute("list"); for(Users u:list){%>
								<option value="<%=u.getId()%>"><%=u.getName() %></option>
							<%}%>
							</select>
						</td>
		    		</tr>
		    		<tr>
		    			<td>收费项目:</td>
		    			<td><input class="easyui-validatebox textbox" type="text" name="xiangmu" data-options="required:true" maxlength="20"></input></td>
		    		</tr>
		    		<tr>
		    			<td>金额:</td>
		    			<td><input class="easyui-numberbox textbox" type="text" name="money" data-options="required:true"  maxlength="11" min="1"></input></td>
		    		</tr>
		    	</table>

				<a href="#" class="easyui-linkbutton" onclick="if($('#form1').form('validate')){$('#form1').submit();}" data-options="iconCls:'icon-ok'" style="margin-right: 80px;margin-top: 20px;">确定</a>
				<a href="#" class="easyui-linkbutton" onclick="$('#form1').form('clear');$('#add').dialog('close');" data-options="iconCls:'icon-cancel'" style="margin-top: 20px;">取消</a>
			</form>
			</div>
	 </div>
  	<!-- 查询 -->
  	<div id="search" class="easyui-dialog" title="查询" data-options="iconCls:'icon-tip',closed:true,modal:true" style="width:480px;height:320px;padding:10px">
		<div align="center">
			<table cellpadding="5" style="color:blueviolet;margin-top: 40px;">
				<tr>
					<td>起始时间</td>
					<td><input id="shijian1" name="shijian1" class="easyui-datebox textbox" type="text" name="birthday" data-options="required:true,editable:false"></input></td>
				</tr>
				<tr>
					<td>结束时间</td>
					<td><input id="shijian2" name="shijian2" class="easyui-datebox textbox" type="text" name="birthday" data-options="required:true,editable:false"></input></td>
				</tr>
			</table>
			<div align="center">
				<a href="#" class="easyui-linkbutton" onclick="sousuo()" data-options="iconCls:'icon-ok'" style="margin-right: 80px;margin-top: 20px;">确定</a>
				<a href="#" class="easyui-linkbutton" onclick="$('#search').dialog('close')" data-options="iconCls:'icon-cancel'" style="margin-top: 20px;">取消</a>
			</div>
		</div>
	 </div>
</html>
